#include <bits/stdc++.h>
#include "../../tools/tools.h"
using namespace std;

constexpr int INF = 0x7fffffff; // 无穷大
typedef long long ll;


class Solution {
public:
    int findWinningPlayer(vector<int>& skills, int k) {
        int winner = 0, win_cnt = 0;
        for (int i = 1; i < skills.size(); i++) {
            if (skills[0] > skills[i]) {
                win_cnt++;
            } else {
                swap(skills[0], skills[i]);
                winner = i;
                win_cnt = 1;
            }
            if (win_cnt == k) break;
        }
        return winner;
    }
};

int main(int argc, const char** argv) {
    Solution s;
    vector<int> data = {4, 2, 6, 3, 9};
    cout << s.findWinningPlayer(data, 2) << endl;
    data = {2,5,4};
    cout << s.findWinningPlayer(data, 3) << endl;
    return 0;
}
